<template>
	<view class="content">
    <!-- <cc-goback title='' color="#fff"></cc-goback> -->
    <view class="navigation_head">
    </view>
    <view class="header">
      登录
    </view>
    <view class="password">
      <view class="word">
        <image src="../../static/login/yonghu.png" mode=""></image>
      </view>
      <input type="text" :value="username" maxlength="11" placeholder="请输入账号"/>
    </view>
    <view class="password">
      <view class="word">
        <image src="../../static/login/mima.png" mode=""></image>
      </view>
      <input :password="ispwd" :value="password" maxlength="15" placeholder="请输入密码"/>
    </view>
	  <view class="btn">
	    <button type="primary" @click="tologin">登录</button>
	  </view>
  </view>
</template>

<script>
	export default {
		data() {
			return {
        ispwd:true,
        // 登录用户名:hztest  密码:123456
        // app客户端账户: hzqAppclient 密码:hzqAppsecret
				username:'hztest',
        password:'123456',
        client:'hzqAppclient',
        secret:'hzqAppsecret',
			};
		},
    onLoad() {
       if (uni.getStorageSync('token')) {
         uni.switchTab({
         	url:'../home/home'
         })
       }
    },
    methods:{
      tologin(){
      	this.$http.post('/auth/oauth/token',{
      		username:this.username,
      		password:this.password,
          grant_type:'password',
          client_id:this.client,
          client_secret:this.secret,
          auth_type:'BAccountPassword',
          scope:'all',
          // type:1,
      	}).then(res=>{
      		console.log('登录',res)
      		if(res.code == '00000'){
      			uni.setStorageSync('token',res.data.accessToken)
            uni.setStorageSync('r_token',res.data.refreshToken)
      			uni.switchTab({
      				url:'../home/home'
      			})
      		}
      	})
      },
    },
    
	}
</script>

<style lang="scss">
 .navigation_head{
    height: calc(88rpx + var(--status-bar-height));
  }
  .header{
    margin: 107rpx 0 132rpx 67rpx;
    font-size: 56rpx;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #333333;
  }
  .password{
    display: flex;
    align-items: center;
    margin: 0 auto;
    width: 690rpx;
    height: 104rpx;
    border-bottom: 1rpx solid #E6E6E6;
  }
  .word{
    margin-right: 40rpx;
    image{
      width: 42rpx;
      height: 42rpx;
    }
    }
    .btn{
      width: 702rpx;
      height: 80rpx;
      margin: 100rpx auto 0;
    }
</style>
